﻿// ----------------------------------------------------------------
// Description : 实体类,该文件由MyGeneration生成
// Author      : 
// Create date : 2009-12-06
// ----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ITOMMS.Entity
{
	/// <summary>
	///	VwTroubleForm Entity
	///	VwTroubleForm Entity
	/// </summary>
	[Serializable]
	public class VwTroubleFormEntity : BaseEntity<VwTroubleFormEntity,int>
	{
		
		#region 私有成员			
		
		private int _ID; 
		private string _TroubleNo; 
		private int _OwnerCompnayID; 
		private string _CompanyName; 
		private int? _ServiceID; 
		private string _ServiceClassName; 
		private int? _TroubleAsset; 
		private string _AssetName; 
		private int? _TaskSource; 
		private string _ShortServiceName; 
		private int? _TroubleClassID; 
		private string _ClassName; 
		private string _TroubleDescription; 
		private int? _AppendixID; 
		private int? _RequestUserID; 
		private DateTime? _RequestTime; 
		private DateTime? _ExpectTime; 
		private int? _State; 
		private string _Incidence; 
		private string _UrgencyDegree; 
		private int? _NextDepartment; 
		private int? _NextPerson; 
		private string _TransactComments; 
		private string _Feedback; 
		private DateTime? _CreateDate; 
		private int? _CreateBy; 
		private DateTime? _ModifyDate; 
		private int? _ModifyBy; 
		private int _SEQNO;
		#endregion


		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public VwTroubleFormEntity()
		{
			_ID = 0; 
			_TroubleNo = String.Empty; 
			_OwnerCompnayID = 0; 
			_CompanyName = String.Empty; 
			_ServiceID =  null; 
			_ServiceClassName = String.Empty; 
			_TroubleAsset =  null; 
			_AssetName = String.Empty; 
			_TaskSource =  null; 
			_ShortServiceName = String.Empty; 
			_TroubleClassID =  null; 
			_ClassName = String.Empty; 
			_TroubleDescription = String.Empty; 
			_AppendixID =  null; 
			_RequestUserID =  null; 
			_RequestTime =  null; 
			_ExpectTime =  null; 
			_State =  null; 
			_Incidence = String.Empty; 
			_UrgencyDegree = String.Empty; 
			_NextDepartment =  null; 
			_NextPerson =  null; 
			_TransactComments = String.Empty; 
			_Feedback = String.Empty; 
			_CreateDate =  null; 
			_CreateBy =  null; 
			_ModifyDate =  null; 
			_ModifyBy =  null; 
			_SEQNO = 0;
		}
		#endregion
		
		#region 属性值校验
		
		/// <summary>
		/// 属性值校验
		/// </summary>
		public bool CheckValues()
		{
			bool bResult = true;
			string strError = "";
		
			if ( _ID ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_ID;
			}
			
			if ( _OwnerCompnayID ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_OwnerCompnayID;
			}
			
			if( !bResult )
					throw new ArgumentOutOfRangeException(strError);
			return bResult;
			
		}
		
		#endregion
		
		
		
	
		#region Required Fields Only Constructor
		
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public VwTroubleFormEntity(
		int para_ID, int para_OwnerCompnayID		)
		: this()
		{
					_ID = para_ID;
			_TroubleNo = String.Empty;
			_OwnerCompnayID = para_OwnerCompnayID;
			_CompanyName = String.Empty;
			_ServiceID = null;
			_ServiceClassName = String.Empty;
			_TroubleAsset = null;
			_AssetName = String.Empty;
			_TaskSource = null;
			_ShortServiceName = String.Empty;
			_TroubleClassID = null;
			_ClassName = String.Empty;
			_TroubleDescription = String.Empty;
			_AppendixID = null;
			_RequestUserID = null;
			_RequestTime = null;
			_ExpectTime = null;
			_State = null;
			_Incidence = String.Empty;
			_UrgencyDegree = String.Empty;
			_NextDepartment = null;
			_NextPerson = null;
			_TransactComments = String.Empty;
			_Feedback = String.Empty;
			_CreateDate = null;
			_CreateBy = null;
			_ModifyDate = null;
			_ModifyBy = null;
		}
		#endregion 

		
		#region 公有属性
			
			/// <summary>
			/// 行号，顺序号。系统默认的属性,对这个属性不要作操作.属性值在架构中已经处理
			/// </summary>
			public virtual int SEQNO
			{
				get { return _SEQNO; }
				set { _SEQNO = value; }
			}
		
			
		/// <summary>
		/// ID
		/// </summary>		
		public virtual int ID
		{
			get { return _ID; }
			set { _ID = value; }
		}
			
		/// <summary>
		/// TroubleNo
		/// </summary>		
		public virtual string TroubleNo
		{
			get { return _TroubleNo; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for TroubleNo", value, value.ToString());
				
				_TroubleNo = value;
			}
		}
			
		/// <summary>
		/// OwnerCompnayID
		/// </summary>		
		public virtual int OwnerCompnayID
		{
			get { return _OwnerCompnayID; }
			set { _OwnerCompnayID = value; }
		}
			
		/// <summary>
		/// CompanyName
		/// </summary>		
		public virtual string CompanyName
		{
			get { return _CompanyName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for CompanyName", value, value.ToString());
				
				_CompanyName = value;
			}
		}
			
		/// <summary>
		/// ServiceID
		/// </summary>		
		public virtual int? ServiceID
		{
			get { return _ServiceID; }
			set { _ServiceID = value; }
		}
			
		/// <summary>
		/// ServiceClassName
		/// </summary>		
		public virtual string ServiceClassName
		{
			get { return _ServiceClassName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for ServiceClassName", value, value.ToString());
				
				_ServiceClassName = value;
			}
		}
			
		/// <summary>
		/// TroubleAsset
		/// </summary>		
		public virtual int? TroubleAsset
		{
			get { return _TroubleAsset; }
			set { _TroubleAsset = value; }
		}
			
		/// <summary>
		/// AssetName
		/// </summary>		
		public virtual string AssetName
		{
			get { return _AssetName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for AssetName", value, value.ToString());
				
				_AssetName = value;
			}
		}
			
		/// <summary>
		/// TaskSource
		/// </summary>		
		public virtual int? TaskSource
		{
			get { return _TaskSource; }
			set { _TaskSource = value; }
		}
			
		/// <summary>
		/// ShortServiceName
		/// </summary>		
		public virtual string ShortServiceName
		{
			get { return _ShortServiceName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for ShortServiceName", value, value.ToString());
				
				_ShortServiceName = value;
			}
		}
			
		/// <summary>
		/// TroubleClassID
		/// </summary>		
		public virtual int? TroubleClassID
		{
			get { return _TroubleClassID; }
			set { _TroubleClassID = value; }
		}
			
		/// <summary>
		/// ClassName
		/// </summary>		
		public virtual string ClassName
		{
			get { return _ClassName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for ClassName", value, value.ToString());
				
				_ClassName = value;
			}
		}
			
		/// <summary>
		/// TroubleDescription
		/// </summary>		
		public virtual string TroubleDescription
		{
			get { return _TroubleDescription; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 2147483647)
						throw new ArgumentOutOfRangeException("Invalid value for TroubleDescription", value, value.ToString());
				
				_TroubleDescription = value;
			}
		}
			
		/// <summary>
		/// AppendixID
		/// </summary>		
		public virtual int? AppendixID
		{
			get { return _AppendixID; }
			set { _AppendixID = value; }
		}
			
		/// <summary>
		/// RequestUserID
		/// </summary>		
		public virtual int? RequestUserID
		{
			get { return _RequestUserID; }
			set { _RequestUserID = value; }
		}
			
		/// <summary>
		/// RequestTime
		/// </summary>		
		public virtual DateTime? RequestTime
		{
			get { return _RequestTime; }
			set { _RequestTime = value; }
		}
			
		/// <summary>
		/// ExpectTime
		/// </summary>		
		public virtual DateTime? ExpectTime
		{
			get { return _ExpectTime; }
			set { _ExpectTime = value; }
		}
			
		/// <summary>
		/// State
		/// </summary>		
		public virtual int? State
		{
			get { return _State; }
			set { _State = value; }
		}
			
		/// <summary>
		/// Incidence
		/// </summary>		
		public virtual string Incidence
		{
			get { return _Incidence; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for Incidence", value, value.ToString());
				
				_Incidence = value;
			}
		}
			
		/// <summary>
		/// UrgencyDegree
		/// </summary>		
		public virtual string UrgencyDegree
		{
			get { return _UrgencyDegree; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 5)
						throw new ArgumentOutOfRangeException("Invalid value for UrgencyDegree", value, value.ToString());
				
				_UrgencyDegree = value;
			}
		}
			
		/// <summary>
		/// NextDepartment
		/// </summary>		
		public virtual int? NextDepartment
		{
			get { return _NextDepartment; }
			set { _NextDepartment = value; }
		}
			
		/// <summary>
		/// NextPerson
		/// </summary>		
		public virtual int? NextPerson
		{
			get { return _NextPerson; }
			set { _NextPerson = value; }
		}
			
		/// <summary>
		/// TransactComments
		/// </summary>		
		public virtual string TransactComments
		{
			get { return _TransactComments; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 1500)
						throw new ArgumentOutOfRangeException("Invalid value for TransactComments", value, value.ToString());
				
				_TransactComments = value;
			}
		}
			
		/// <summary>
		/// Feedback
		/// </summary>		
		public virtual string Feedback
		{
			get { return _Feedback; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 1500)
						throw new ArgumentOutOfRangeException("Invalid value for Feedback", value, value.ToString());
				
				_Feedback = value;
			}
		}
			
		/// <summary>
		/// CreateDate
		/// </summary>		
		public virtual DateTime? CreateDate
		{
			get { return _CreateDate; }
			set { _CreateDate = value; }
		}
			
		/// <summary>
		/// CreateBy
		/// </summary>		
		public virtual int? CreateBy
		{
			get { return _CreateBy; }
			set { _CreateBy = value; }
		}
			
		/// <summary>
		/// ModifyDate
		/// </summary>		
		public virtual DateTime? ModifyDate
		{
			get { return _ModifyDate; }
			set { _ModifyDate = value; }
		}
			
		/// <summary>
		/// ModifyBy
		/// </summary>		
		public virtual int? ModifyBy
		{
			get { return _ModifyBy; }
			set { _ModifyBy = value; }
		}
			


		#endregion 	
		
		
        #region DAO操作
		
		
		/// <summary>
        /// 获取所有实体的列表
        /// </summary>
        /// <returns></returns>
        public override List<VwTroubleFormEntity> GetAll()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_TroubleForm] ");
	
            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = 0;
                while (dataReader.Read())
                {	seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [Vw_TroubleForm] ");
	
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords(string sqlCondition)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [Vw_TroubleForm]  ");
	
			 if (sqlCondition.Trim() != "")
            {
                strSql.Append(" where " + sqlCondition);
            }
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }	
		
		
		/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
        /// <returns></returns>
		 public override List<VwTroubleFormEntity> GetAllByQuery(string strWhere, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_TroubleForm] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [Vw_TroubleForm] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere );
            }
			strSql.Append(" ) " );

            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
			   int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
			/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
		/// <param name="strSort">ex:order by id desc</param>
        /// <returns></returns>
		 public override List<VwTroubleFormEntity> GetAllByQuery(string strWhere,string strSort, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_TroubleForm] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [Vw_TroubleForm] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere+" " ).Append(strSort);
            }
			strSql.Append(" ) " ).Append(strSort);

            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public override List<VwTroubleFormEntity> GetAllByQuery(string strWhere)
        {
			strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from Vw_TroubleForm ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            { 
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
		/// <param name="parameters">sql条件中的参数</param>
        /// <returns></returns>
        public override List<VwTroubleFormEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_TroubleForm] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
				int seq =0 ;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		

		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<VwTroubleFormEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters, int rowNumber)
        {

            StringBuilder strSql = new StringBuilder();
			strSql.Append("select top ").Append(rowNumber).Append("  [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_TroubleForm] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {	
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句: AND AA=@AA</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<VwTroubleFormEntity> GetAllByQuery(string strWhere, int rowNumber)
        {
		    strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			
			strSql.Append("select top ").Append(rowNumber).Append("  [ID],[TroubleNo],[OwnerCompnayID],[CompanyName],[ServiceID],[ServiceClassName],[TroubleAsset],[AssetName],[TaskSource],[ShortServiceName],[TroubleClassID],[ClassName],[TroubleDescription],[AppendixID],[RequestUserID],[RequestTime],[ExpectTime],[State],[Incidence],[UrgencyDegree],[NextDepartment],[NextPerson],[TransactComments],[Feedback],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_TroubleForm] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where  " + strWhere);
            }
            List<VwTroubleFormEntity> list = new List<VwTroubleFormEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq=0;
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		
		
			
		
		/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private VwTroubleFormEntity ReaderBind(IDataReader dataReader,int seq)
        {
            ITOMMS.Entity.VwTroubleFormEntity entity = new ITOMMS.Entity.VwTroubleFormEntity();
			entity.SEQNO = seq;
            object obj;
						 obj=dataReader["ID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ID= (int)obj;
			}
			 entity.TroubleNo= dataReader["TroubleNo"].ToString();
			 obj=dataReader["OwnerCompnayID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.OwnerCompnayID= (int)obj;
			}
			 entity.CompanyName= dataReader["CompanyName"].ToString();
			 obj=dataReader["ServiceID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ServiceID= (int)obj;
			}
			 entity.ServiceClassName= dataReader["ServiceClassName"].ToString();
			 obj=dataReader["TroubleAsset"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.TroubleAsset= (int)obj;
			}
			 entity.AssetName= dataReader["AssetName"].ToString();
			 obj=dataReader["TaskSource"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.TaskSource= (int)obj;
			}
			 entity.ShortServiceName= dataReader["ShortServiceName"].ToString();
			 obj=dataReader["TroubleClassID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.TroubleClassID= (int)obj;
			}
			 entity.ClassName= dataReader["ClassName"].ToString();
			 entity.TroubleDescription= dataReader["TroubleDescription"].ToString();
			 obj=dataReader["AppendixID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.AppendixID= (int)obj;
			}
			 obj=dataReader["RequestUserID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.RequestUserID= (int)obj;
			}
			 obj=dataReader["RequestTime"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.RequestTime= (DateTime)obj;
			}
			 obj=dataReader["ExpectTime"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ExpectTime= (DateTime)obj;
			}
			 obj=dataReader["State"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.State= (int)obj;
			}
			 entity.Incidence= dataReader["Incidence"].ToString();
			 entity.UrgencyDegree= dataReader["UrgencyDegree"].ToString();
			 obj=dataReader["NextDepartment"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.NextDepartment= (int)obj;
			}
			 obj=dataReader["NextPerson"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.NextPerson= (int)obj;
			}
			 entity.TransactComments= dataReader["TransactComments"].ToString();
			 entity.Feedback= dataReader["Feedback"].ToString();
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}

            return entity;
        }
		
		
				/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private VwTroubleFormEntity ReaderBind(IDataReader dataReader)
        {
            ITOMMS.Entity.VwTroubleFormEntity entity = new ITOMMS.Entity.VwTroubleFormEntity();
			object obj;
						 obj=dataReader["ID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ID= (int)obj;
			}
			 entity.TroubleNo= dataReader["TroubleNo"].ToString();
			 obj=dataReader["OwnerCompnayID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.OwnerCompnayID= (int)obj;
			}
			 entity.CompanyName= dataReader["CompanyName"].ToString();
			 obj=dataReader["ServiceID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ServiceID= (int)obj;
			}
			 entity.ServiceClassName= dataReader["ServiceClassName"].ToString();
			 obj=dataReader["TroubleAsset"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.TroubleAsset= (int)obj;
			}
			 entity.AssetName= dataReader["AssetName"].ToString();
			 obj=dataReader["TaskSource"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.TaskSource= (int)obj;
			}
			 entity.ShortServiceName= dataReader["ShortServiceName"].ToString();
			 obj=dataReader["TroubleClassID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.TroubleClassID= (int)obj;
			}
			 entity.ClassName= dataReader["ClassName"].ToString();
			 entity.TroubleDescription= dataReader["TroubleDescription"].ToString();
			 obj=dataReader["AppendixID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.AppendixID= (int)obj;
			}
			 obj=dataReader["RequestUserID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.RequestUserID= (int)obj;
			}
			 obj=dataReader["RequestTime"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.RequestTime= (DateTime)obj;
			}
			 obj=dataReader["ExpectTime"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ExpectTime= (DateTime)obj;
			}
			 obj=dataReader["State"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.State= (int)obj;
			}
			 entity.Incidence= dataReader["Incidence"].ToString();
			 entity.UrgencyDegree= dataReader["UrgencyDegree"].ToString();
			 obj=dataReader["NextDepartment"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.NextDepartment= (int)obj;
			}
			 obj=dataReader["NextPerson"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.NextPerson= (int)obj;
			}
			 entity.TransactComments= dataReader["TransactComments"].ToString();
			 entity.Feedback= dataReader["Feedback"].ToString();
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}

            return entity;
        }
		
		
		
		 #endregion
		
	}
}
